package com.ews.onlineexchange.controller;

import java.io.Serializable;

import javax.enterprise.context.Conversation;
import javax.enterprise.context.SessionScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import com.ews.onlineexchange.service.UserService;

@SessionScoped
@Named
public class AuthContoller implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Inject
	protected Conversation				conversation;
	@Inject
	UserService userService;
	public void logout() throws ServletException {
		if (!conversation.isTransient()) {
			conversation.end();
		}
		userService.setLoginedUser(null);
		HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
		req.logout();
	}
}
